setVariableBinding

abstract fun setVariableBinding(block: DesignBlock, property: String, key: String)

Bind a block property to a color, number, image or typeface variable, and apply the variable's current value. Color variables bind to color properties and number variables to float properties. Image variables bind only to "fill/image/imageFileURI", "fill/image/previewFileURI" and "fill/video/fileURI". Typeface variables bind only to "text/typeface" and "caption/typeface". A direct write to a bound property fails with BLOCK.PROPERTY_BOUND until the binding is removed. A bound typeface also locks setTypeface and setFont. On a text block, a variable bound to "fill/solid/color" or the font size sets every run of the text, and setTextColor or setTextFontSize fails for any range. Keyframes, undo and scene loads still change it. Changing the design unit converts a bound length. A number variable whose bound properties all hold its value converts with them. Otherwise the variable keeps its value, and the next variable write sets the lengths in the new unit. Experimental: this API may change in a minor release.

Parameters

block

the block that has the property.

property

the property path, for example "fill/color/value".

key

the key of an existing variable.